package org.taobao.ibatiside.ui.action;

import org.eclipse.core.resources.IFile;
import org.eclipse.datatools.sqltools.editor.core.connection.ISQLEditorConnectionInfo;
import org.eclipse.datatools.sqltools.internal.sqlscrapbook.util.SQLFileUtil;
import org.eclipse.jface.wizard.WizardDialog;
import org.taobao.ibatiside.ui.Activator;
import org.taobao.ibatiside.ui.wizard.ConnectionToConfigurationWizard;

//Only support JDBC
public class ConnectionToConfigurationAction extends AbstractViewerAction {
	public static final String ID="org.taobao.ibatiside.ui.action.dse.c2c";
	
	public ConnectionToConfigurationAction() {
		super();
		setId(ID);
		setText("Generate Configuration");
		setImageDescriptor(Activator.getIcon("eview16/xmlconfig.png"));
		setDescription("Generate Spring Or Ibatis configuration file base on option");
	}

	@Override
	public void run() {
		ISQLEditorConnectionInfo connectionInfo = SQLFileUtil.getSelectedConnectionInfo();
		ConnectionToConfigurationWizard newWizard = new ConnectionToConfigurationWizard(connectionInfo);
		WizardDialog c2c_dialog = new WizardDialog(viewer.getTree().getShell(), newWizard);
		if (c2c_dialog.open() == WizardDialog.OK){
			IFile genereted_file = newWizard.getMergedFile();
			postGenerating(genereted_file);
		}
	}

	private void postGenerating(IFile genereted_file) {
		
	}
}
